package MyBlog.dao.impl;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import MyBlog.dao.AlbumDao;
import MyBlog.entity.Album;

@Repository("albumDao")
public class AlbumDaoImpl implements AlbumDao {
	
	@Autowired
	private HibernateTemplate hibernateTemplate;

	public List<Album> getAlbumsById(int userId) {
		return (List<Album>) hibernateTemplate.find("from Album a where a.user.id=?",userId);
	}

	@Override
	public Album getAlbumById(int id) {
		return hibernateTemplate.get(Album.class, id);
	}

	@Override
	public void add(Album album) {
		hibernateTemplate.save(album);
	}

	@Override
	public void update(Album album) {
		hibernateTemplate.update(album);
	}
	

}
